home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / gplot3_2.lha / gnuplot / term / t410x.trm < prev    next >
Text File  |  1992-03-25  |  5KB  |  244 lines

  1. /*
  2.  * $Id: t410x.trm,v 3.26 92/03/24 22:35:44 woo Exp Locker: woo $
  3.  */
  4.  
  5. /* GNUPLOT - t410x.trm */
  6. /*
  7.  * Copyright (C) 1990, 1991, 1992   
  8.  *
  9.  * Permission to use, copy, and distribute this software and its
  10.  * documentation for any purpose with or without fee is hereby granted, 
  11.  * provided that the above copyright notice appear in all copies and 
  12.  * that both that copyright notice and this permission notice appear 
  13.  * in supporting documentation.
  14.  *
  15.  * Permission to modify the software is granted, but not the right to
  16.  * distribute the modified code.  Modifications are to be distributed 
  17.  * as patches to released version.
  18.  *  
  19.  * This software  is provided "as is" without express or implied warranty.
  20.  * 
  21.  * This file is included by ../term.c.
  22.  *
  23.  * This terminal driver supports: Tektronix 410x and 420x series terminals
  24.  *
  25.  * AUTHORS
  26.  *   Colin Kelley, Thomas Williams
  27.  * 
  28.  * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
  29.  * 
  30.  */
  31.  
  32. /* Tektronix 410X and 420X driver written by Cary D. Renzema.
  33.  * email address: caryr@vice.ico.tek.com
  34.  *
  35.  * I've tested this driver on the following terminals: 4106, 4107A, 4109
  36.  * and 4207.  It should work, without editing, on other terminals in the
  37.  * 410x and 420x families.  It will probably need to be changed to work
  38.  * on a 4105 (screen size and character rotation are two guesses).  This
  39.  * file can also be used as a start for a 411x driver.
  40.  *
  41.  * Cary R.
  42.  * April 5, 1990
  43.  */
  44.  
  45. #ifdef T410X
  46.  
  47. #define T410XXMAX 4095
  48. #define T410XYMAX 3131
  49.  
  50. #define T410XVCHAR    71
  51. #define T410XHCHAR    51
  52. #define T410XVTIC    36
  53. #define T410XHTIC    36    
  54.  
  55. static int T410X_angle=0;
  56.  
  57. T410X_init()
  58. {
  59.     (void) fprintf(outfile, "\033%%!0\033MN0\033MCB7C;\033MQ1\033MT1");
  60.     (void) fprintf(outfile, "\033MG1\033RK!\033SK!\033LZ\033%%!1");
  61. /*
  62.      1. set tek mode
  63.      2. set character path to 0 (characters placed equal to rotation)
  64.      3. set character size to 59 height
  65.      4. set character precision to string
  66.      5. set character text index to 1
  67.      6. set character write mode to overstrike
  68.      7. clear the view
  69.      8. clear the segments
  70.      9. clear the dialog buffer
  71.     10. set ansi mode
  72. */
  73.     (void) fflush(outfile);
  74. }
  75.  
  76.  
  77. T410X_reset()
  78. {
  79.     (void) fprintf(outfile, "\033%%!0\033LZ\033%%!1");
  80. /*
  81.     1. set tek mode
  82.     2. clear the dialog buffer
  83.     3. set ansi mode
  84. */
  85.     (void) fflush(outfile);
  86. }
  87.  
  88.  
  89. T410X_graphics()
  90. {
  91.     (void) fprintf(outfile, "\033%%!0\033\014\033LV0");
  92. /*
  93.     1. set tek mode
  94.     2. clear the screen
  95.     3. set dialog area invisible
  96. */
  97.     (void) fflush(outfile);
  98. }
  99.  
  100. T410X_text()
  101. {
  102.     (void) fprintf(outfile, "\033LV1\033%%!1");
  103. /*
  104.     1. set dialog area visible
  105.     2. set ansi mode
  106. */
  107.     (void) fflush(outfile);
  108. }
  109.  
  110.  
  111. T410X_move(x, y)
  112. unsigned int x, y;
  113. {
  114.     (void) fprintf(outfile, "\033LF");
  115.     (void) T410X_encode_x_y(x, y);
  116.     (void) fflush(outfile);
  117. }
  118.  
  119.  
  120. T410X_vector(x, y)
  121. unsigned int x, y;
  122. {
  123.     (void) fprintf(outfile, "\033LG");
  124.     (void) T410X_encode_x_y(x, y);
  125.     (void) fflush(outfile);
  126. }
  127.  
  128.  
  129. T410X_point(x, y, number)
  130. unsigned int x, y;
  131. int number;
  132. {
  133.     (void) fprintf(outfile, "\033MM");
  134.     (void) T410X_encode_int(max(number, 0)%11);
  135.     (void) fprintf(outfile, "\033LH");
  136.     (void) T410X_encode_x_y(x, y);
  137.     (void) fflush(outfile);
  138. }
  139.  
  140.  
  141. T410X_linetype(linetype)
  142. int linetype;
  143. {
  144.     switch (linetype) {
  145.         case -1:
  146.             (void) fprintf(outfile, "\033ML5");
  147.             break;
  148.         case -2:
  149.             (void) fprintf(outfile, "\033ML?");
  150.             break;
  151.         default:
  152.             (void) fprintf(outfile, "\033ML");
  153.             (void) T410X_encode_int(linetype%14+2);
  154.             break;
  155.     }
  156.     (void) fprintf(outfile, "\033MV");
  157.     (void) T410X_encode_int(max(linetype, 0)%8);
  158.     (void) fflush(outfile);
  159. }
  160.  
  161.  
  162. T410X_put_text(x, y, str)
  163. unsigned int x, y;
  164. char str[];
  165. {
  166.     extern int T410X_angle;
  167.  
  168.     if (T410X_angle == 0) {
  169.         (void) T410X_move(x, y-T410XVCHAR/2+6);
  170.         (void) fprintf(outfile, "\033MR00");
  171.     } else {
  172.         (void) T410X_move(x+T410XHCHAR/2-6, y);
  173.         (void) fprintf(outfile, "\033MRE:0");
  174.     }
  175.     (void) fprintf(outfile, "\033LT");
  176.     (void) T410X_encode_int(strlen(str));
  177.     (void) fputs(str, outfile);
  178.     (void) fflush(outfile);
  179. }
  180.  
  181. T410X_text_angle(ang)
  182. int ang;
  183. {
  184.     extern int T410X_angle;
  185.  
  186.     T410X_angle = ang;
  187.     return(TRUE);
  188. }
  189.  
  190. /* These last two routines are based on fortran code found in the
  191.  * 4106/4107/4109/CX PROGRAMMERS manual.
  192.  */
  193.  
  194. T410X_encode_x_y(x, y)
  195. unsigned int x, y;
  196. {
  197.     static char chix=0, chiy=0, cloy=0, ceb=0;
  198.  
  199.     register unsigned int hix, lox, hiy, loy, eb, lx, ly;
  200.  
  201.     lx = (x <= T410XXMAX) ? x : T410XXMAX;
  202.     ly = (y <= T410XYMAX) ? y : T410XYMAX;
  203.  
  204.     hix = lx/128 + 32;
  205.     lox = (lx/4)%32 + 64;
  206.     hiy = ly/128 + 32;
  207.     loy = (ly/4)%32 + 96;
  208.     eb = (ly%4)*4 + lx%4 + 96;
  209.  
  210.     if (chiy != hiy) (void) putc(hiy, outfile);
  211.     if (ceb != eb) (void) putc(eb, outfile);
  212.     if ((cloy!=loy) || (ceb!=eb) || (chix!=hix)) (void) putc(loy, outfile);
  213.     if (chix != hix) (void) putc(hix, outfile);
  214.     (void) putc(lox, outfile);
  215.  
  216.     chix = hix;
  217.     chiy = hiy;
  218.     cloy = loy;
  219.     ceb = eb;
  220. }
  221.  
  222.  
  223. T410X_encode_int(number)
  224. int number;
  225. {
  226.     register unsigned int mag, hi1, hi2, lo;
  227.  
  228.     mag = abs(number);
  229.  
  230.     hi1 = mag/1024 + 64;
  231.     hi2 = (mag/16)%64 + 64;
  232.     lo = mag%16 + 32;
  233.  
  234.     if (number >= 0) lo += 16;
  235.  
  236.     if (hi1 != 64) (void) putc(hi1, outfile);
  237.     if ((hi2 != 64) || (hi1 != 64)) (void) putc(hi2, outfile);
  238.     (void) putc(lo, outfile);
  239.  
  240. }
  241.  
  242.  
  243. #endif /* T410X */
  244.